/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package clases;

import javax.servlet.http.HttpServletRequest;
import java.util.regex.*;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author tamerdark
 */
public class Profesor extends Usuario {

  private int nivel;

  public Profesor() {
  }

  public int getNivel() {
    return nivel;
  }

  public void setNivel(int nivel) {
    this.nivel = nivel;
  }

  public void cleanAttributes() {
    super.cleanAttributes();;
    setNivel(0);
  }

  /**
   * This is the action called from the Struts framework.
   * @param mapping The ActionMapping used to select this instance.
   * @param request The HTTP Request we are processing.
   * @return
   */
  @Override
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = super.validate(mapping, request);
    if (this.nivel <= 0) {
      errors.add("nivel", new ActionMessage("errors.nivel"));
    }
    mapping.getInputForward();
    return errors;
  }
}
